@extends('layouts.app')
@include('order.sidebar')
@section('content')
    <div class="content">
        <div class="row custom-invoice">
            <form method="post" action="{{ route('admin.order.store') }}" accept-charset="UTF-8" enctype="multipart/form-data">
                <input type="hidden"  name="_token" value="{{ csrf_token() }}"/>
                <input type="hidden" name="user_id" value="{{ $formData['user_id'] }}" />
                <input type="hidden" name="link_id" value="{{ $formData['link_id'] }}" />
                <input type="hidden" name="type" value="{{ $formData['type'] }}" />
                <input type="hidden" name="price" value="{{ $formData['price'] }}" />
                @if(!is_null($formData['bill']))
                    @foreach($formData['bill'] as $value)
                        <input type="hidden" name="bill[]" value="{{ $value }}" />
                    @endforeach
                @endif
                <div class="form-group">
                    <label for="name">推荐人: {{ $referrer }}</label>
                </div>
                <div class="form-group">
                    <label for="name">预约时间</label>
                    <input name="deliver_date" id="deliver_date" class="form-control" required/>
                </div>
                <div class="form-group">
                    <label for="mobile">电话</label>
                    <input name="mobile" id="mobile" class="form-control" required/>
                </div>
                <div class="form-group">
                    <label for="">选择产品</label>
                </div>
                <div class="form-group">
                    @foreach($attrValue as $key => $item)
                        <div class="form-group" style="margin-top: 20px">
                            <p style="font-size: 28px; font-weight: bold">{{ $attr->get($key)->name }}</p>
                        </div>
                        <div class="row">
                            @foreach($item as $item1)
                                @php
                                    $spec = $data->get($item1->id);
                                @endphp
                                <div class="form-group col-md-4 col-sm-6 col-xs-10">
                                    <label for="{{ "spec".$item1->id }}">{{ $item1->value }}:</label>
                                    <input type="text" class="form-control" name="spec[{{ $spec->id }}]" id="{{ "spec".$item1->id }}" value="{{ isset($default[$item1->id])? $default[$item1->id]['number'] : '' }}" placeholder="数量"/>
                                </div>
                            @endforeach
                        </div>
                    @endforeach
                </div>
                <br />
                <br />
                <button type="submit" class="form-control btn btn-success">创建订单</button>
            </form>
        </div>
    </div>
@endsection
@push('scripts')
    <script>

        $('.refund').on('click', function () {
            $("#hideForm form").attr('action', $(this).attr('data-url'));
            $("#hideForm").modal('show');
        });
        $('#closeHideForm').on('click', function () {
            $("#hideForm").modal('hide');
        });

        $('.change-price').on('click', function () {
            $("#hideForm form").attr('action', $(this).attr('data-url'));
            $("#hideForm").modal('show');
        });
        // $('#deliver_date').datetimepicker({format:"YYYY-MM-DD"});
        $("#deliver_date").datetimepicker({format: "Y-m-d",timepicker:false});
        $.datetimepicker.setLocale('zh');
    </script>
@endpush


